package com.huizhonglm.diap.core.utils;

import com.huizhonglm.diap.core.storage.db.DBMethod;
import com.huizhonglm.diap.core.storage.model.UserInfo;

/**
 * 描述当前类的作用
 *
 * @author LiXiaoLong
 * @version 1.0
 * @since 2016-03-01 23:31
 */
public class UserUtil {

    public static boolean isLogin(){
        UserInfo user = DBMethod.getInstance().findUserInfo();
        return user != null;
    }

    public static void logout(){
        DBMethod.getInstance().deleteUserInfo();
    }

    public static String getUserId(){
        UserInfo user = DBMethod.getInstance().findUserInfo();
        return user != null ? user.getUserId() : null;
    }

    public static UserInfo getUserInfo(){
        return DBMethod.getInstance().findUserInfo();
    }

    public static void saveUserInfo(UserInfo info){
        DBMethod.getInstance().saveUserInfo(info);
    }
}
